﻿
@{
    Layout = "~/Views/Shared/_LayoutForEUI.cshtml";
    var listType = ViewBag.Type as List<SGArchiveSystem7x.Models.CComboboxModel>;
    var listColumns = ViewBag.Columns as List<SGArchiveSystem7x.Models.CColumnsModel>;
}
<table id="LogArchiveInit_Index_grid" class="easyui-datagrid" style="width:100%;" title="档案操作日志" data-options="
       rownumbers:true,
       singleSelect:true,
       autoRowHeight:false,
       pagination:true,
       fitColumns:true,
       fit:true,
       striped:true,
       checkOnSelect:false,
       selectOnCheck:false,
       toolbar:'#LogArchiveInit_Index_tb',
       collapsible:false,
       pageSize: @SGArchiveSystem7x.Models.CCommonsModels.PageSize,
       pageList:[10,15,20]">
    <thead frozen="true">
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
    <thead>
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (!c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
</table>

<div id="LogArchiveInit_Index_tb" style="padding:2px 5px;">
    <select class="easyui-combobox" label="档案类型:" labelwidth="60px" style="width:180px" id="LogArchiveInit_Index_cmbType" editable="false" panelHeight="auto">
        @{
            foreach (var item in listType)
            {
                <option value="@item.ID">@item.Text</option>
            }
        }
    </select>
    <input type="text" class="easyui-textbox" label="档号:" labelwidth="40px" style="width:180px" id="LogArchiveInit_Index_txtDH" />
    <input type="text" class="easyui-datebox" data-options="editable:false" label="起始时间:" labelwidth="60px" style="width:180px" id="LogArchiveInit_Index_txtSTime" />
    <input type="text" class="easyui-datebox" data-options="editable:false" label="结束时间:" labelwidth="60px" style="width:180px" id="LogArchiveInit_Index_txtETime" />
    <input type="text" class="easyui-textbox" label="操作人:" labelwidth="50px" style="width:180px" id="LogArchiveInit_Index_txtCZR" />
    <select class="easyui-combobox" label="操作类型:" labelwidth="60px" style="width:180px" id="LogArchiveInit_Index_cmbCZLX" editable="false" panelHeight="auto">
        <option>全部</option>
        <option>著录</option>
        <option>修改</option>
        <option>删除</option>
        <option>电子文件上传</option>
    </select>
    <a href="javascript:void(0);" id="LogArchiveInit_Index_btnQuery" class="easyui-linkbutton button-blue" iconCls="icon-search" onclick="Search()" style="width:110px;height:30px;">查询</a>
    <a href="javascript:void(0);" id="LogArchiveInit_Index_btnDownload" class="easyui-linkbutton button-blue" iconCls="icon-redo" onclick="Download()" style="width:110px;height:30px;">导出xls</a>
</div>

<script>
    var list=@Html.Raw(Json.Encode(listType));
    $(function () {
        $('#LogArchiveInit_Index_grid').datagrid({
            url:'/LogArchiveInit/Get_ajaxLogArchiveInitList?type=-1&DH&starttime&endtime&CZR&CZLX',
            singleSelect: true,
            method: 'post',
            onLoadSuccess: function (data) {
                $('.pagination-page-list').hide();
            }
        });
        InitPagenation();
    })

    ///初始化分页
    function InitPagenation() {
        //设置分页控件
        var p = $('#LogArchiveInit_Index_grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                SearchPager(pageNumber, pageSize);
            }
        })
    }

        function SearchPager(num, size) {

            $('#LogArchiveInit_Index_grid').datagrid('options').url = '/LogArchiveInit/Get_ajaxLogArchiveInitListPager?num=' + num + '&size=' + size;
            $('#LogArchiveInit_Index_grid').datagrid('reload');
            $('#LogArchiveInit_Index_grid').datagrid('options').pageNumber = num;
            $('#LogArchiveInit_Index_grid').datagrid('options').pageSize = size;
        }

    //查询
    function Search() {
        var type = $('#LogArchiveInit_Index_cmbType').combobox('getValue');
        var DH = $('#LogArchiveInit_Index_txtDH').val();
        var stime = $('#LogArchiveInit_Index_txtSTime').datebox('getValue');
        var etime = $('#LogArchiveInit_Index_txtETime').datebox('getValue');
        var CZR = $('#LogArchiveInit_Index_txtCZR').val();
        var CZLX = $('#LogArchiveInit_Index_cmbCZLX').combobox('getText');
        $('#LogArchiveInit_Index_grid').datagrid('options').url = '/LogArchiveInit/Get_ajaxLogArchiveInitList?type=' + type + '&DH=' + DH + '&starttime=' + stime + '&endtime=' + etime + '&CZR=' + CZR + '&CZLX=' + CZLX
        $('#LogArchiveInit_Index_grid').datagrid('load');
    }
    function Download() {
        var type = $('#LogArchiveInit_Index_cmbType').combobox('getValue');
        var DH = $('#LogArchiveInit_Index_txtDH').val();
        var stime = $('#LogArchiveInit_Index_txtSTime').datebox('getValue');
        var etime = $('#LogArchiveInit_Index_txtETime').datebox('getValue');
        var CZR = $('#LogArchiveInit_Index_txtCZR').val();
        var CZLX = $('#LogArchiveInit_Index_cmbCZLX').combobox('getText');
        var grid = $('#LogArchiveInit_Index_grid');
        var options = grid.datagrid('getPager').data("pagination").options;
        var total = options.total;
        if (total > 100) {
            if (window.confirm('数据量过多，是否仍然需要导出？')) {
                $.ajax({
                    url: '/LogArchiveInit/DownLoadxls?type=' + type + '&DH=' + DH + '&starttime=' + stime + '&endtime=' + etime + '&CZR=' + CZR + '&CZLX=' + CZLX ,
                    dataType: "text",
                    type: "post",
                    success: function (data) {
                        window.open(data);
                    }
                });
            }
        }
        else {
            $.ajax({
                url: '/LogArchiveInit/DownLoadxls?type=' + type + '&DH=' + DH + '&starttime=' + stime + '&endtime=' + etime + '&CZR=' + CZR + '&CZLX=' + CZLX ,
                dataType: "text",
                type: "post",
                success: function (data) {
                    alert('下载');
                    window.open(data);
                }
            });
        }
    }

    function formatDate(value, row) {
        if (value != null) {
            var time = new Date(parseInt(value.substr(6, 19)))//.toLocaleDateString();//13
            return time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
        }
        else {
            return "";
        }
    }
    function formatTYPE(value, row) {
       // alert(value);
       // alert(list);
        for (var i = 0; i < list.length; i++) {
            if (list[i].ID == value) {
                return list[i].Text;
            }
        }
        return -1;
    }
</script>